package com.zg.autoform.dto;

import lombok.Data;

import java.util.Map;

/**
 * 重复数据检查结果
 * @author zg
 */
@Data
public class DuplicateCheckResult {

    /**
     * 是否重复
     */
    private Boolean isDuplicate;

    /**
     * 重复的记录ID（用于覆盖操作）
     */
    private Long duplicateId;

    /**
     * 重复的字段值
     */
    private Map<String, Object> duplicateFields;

    /**
     * 重复数据的完整记录
     */
    private Map<String, Object> duplicateRecord;

    /**
     * 重复检查的字段名
     */
    private String checkFields;

    /**
     * 重复原因描述
     */
    private String duplicateReason;

    public static DuplicateCheckResult noDuplicate() {
        DuplicateCheckResult result = new DuplicateCheckResult();
        result.setIsDuplicate(false);
        return result;
    }

    public static DuplicateCheckResult duplicate(Long duplicateId, Map<String, Object> duplicateFields, 
                                               String checkFields, String reason) {
        DuplicateCheckResult result = new DuplicateCheckResult();
        result.setIsDuplicate(true);
        result.setDuplicateId(duplicateId);
        result.setDuplicateFields(duplicateFields);
        result.setCheckFields(checkFields);
        result.setDuplicateReason(reason);
        return result;
    }
}
